<template>
  <main class="heart-card-page">
    <div class="header">
      <p class="page-title">购买延长壳牌(广东)石油有限公司加油卡</p>
      <img src="~assets/images/shop_logo.jpg" alt="" class="logo">
    </div>
    <div v-if="false">
      <p class="title">实时油价</p>
      <ul class="gas-price">
        <li>
          <p>优惠价</p>
          <p class="rmb">4.61</p>
        </li>
        <li>
          <p>优惠</p>
          <p class="rmb">0.5元/升</p>
        </li>
        <li>
          <p>油站价</p>
          <p class="rmb">5.11</p>
        </li>
      </ul>
    </div>
    <!-- <van-divider /> -->
    <div>
      <p class="title">选择购买的油品</p>
      <div class="gas-type">
        <span class="active">柴油0#</span>
        <span class="disabled">汽油92</span>
        <span class="disabled">汽油95</span>
        <span class="disabled">汽油98</span>
      </div>
    </div>
    <van-divider />
    <div>
      <p class="title">输入金额</p>
      <div class="input-box">
        <van-field 
          class="gas-input"
          v-model="order_amount" 
          placeholder="在这里输入加油金额"
          type="digit"
          maxlength="4"
          input-align="center"/>
      </div>
      <van-button 
        type="primary" 
        @click="submitOrder"
        color="linear-gradient(to right, #FF9800, #FF5722)"
        block >
        确定
      </van-button>
    </div>
    <van-divider />
    <div class="tip-box">
      <!-- <p class="title">注意事项：</p> -->
      <p>1、所有加油卡为我司在延长壳牌(广东)石油有限公司的预付款加油卡；</p>
      <p>2、所有加油款项均为运输油费；</p>
      <p>3、如有问题请及时联系客服。</p>
    </div>
  </main>
</template>

<script>
import { Toast } from 'vant';
import {mapGetters, mapActions} from 'vuex'

export default {
  name: 'heart-card',
  data() {
    return {
      order_amount: '',
    }
  },
  computed: {
    ...mapGetters([
      'user',
    ])
  },
  created() {
    this.$emit('showTabMenu', true);
  },
  methods: {
    ...mapActions([
      'setHeartCard'
    ]),
    submitOrder () {
      if (!this.order_amount) {
        Toast('金额不能为空')
        return
      }
      if (this.order_amount > 5000) {
        // Toast.fail('失败文案');
        Toast('单笔金额不能超过5000元')
        return
      }
      let params = {
        gas_Type: '柴油0#',
        order_amount: String(Number(this.order_amount) * 100),
        phone: this.user.phone,
        station_id: '4400018137',
      }
      this.setHeartCard(params)
      this.$router.push({name: 'Order'})
    }
  }
}
</script>

<style lang="less" scoped>
.header{
  text-align: center;
  .page-title{
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    line-height: 40px;
    padding: 10px 0;
  }
  .logo{
    width: 80px
  }
}
.heart-card-page{
  padding: 0 20px;
  font-size: 14px;
  .title{
    font-weight: bold;
    font-size: 14px;
    line-height: 40px;
  }
}
.gas-type{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  span{
    height: 40px;
    line-height: 40px;
    background: #eee;
    text-align: center;
    border-radius: 4px;
    &.active{
      background: #fff5d6;
      border: 1px solid #FF9800;
      color: #FF9800;
    }
    &.disabled{
      color: #a0a0a0;
      cursor: no-drop;
    }
  }
}
.gas-price{
  display: flex;
  justify-content: space-around;
  color: #FF9800;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  background: #fff5d5;
  padding: 8px;
}
.input-box{
  height: 56px;
  width: 100%;
  background: #fff5d6;
  border: 1px solid #FF9800;
  border-radius: 5px;
  margin-bottom: 20px;
  .gas-input{
    background: transparent;
    font-size: 18px;
    font-weight: bold;
    padding: 15px 16px;
    /deep/ input{
      line-height: 28px;
      &::-webkit-input-placeholder{
        font-size: 16px;
        font-weight: 400;
      }
    }
  }
}

</style>
